from tools.SentenceTransformerTools import VectorTool

# 创建向量工具实例
vector_tool = VectorTool()

# 1. 测试向量生成
test_text = "这是一个测试文本"
vector = vector_tool.generate_vector(test_text)
print(f"测试文本向量维度: {len(vector)}")

test_text = "修车"
vector = vector_tool.generate_vector(test_text)
print(f"修车: {len(vector)}")

# 2. 输入待比较的语句
sentence1 = "自然语言处理很有趣"
sentence2 = "NLP技术非常吸引人"

# 3. 计算语义相似度
similarity = vector_tool.compute_similarity(sentence1, sentence2)
print(f"语义相似度：{similarity.item():.4f}")

# 4. 批量相似度计算示例
sentences1 = ["机器学习很有趣", "深度学习技术发展迅速"]
sentences2 = ["人工智能很吸引人", "神经网络进步很快"]

batch_similarity = vector_tool.compute_similarity(sentences1, sentences2)
print("批量相似度矩阵:")
print(batch_similarity)